package com.campusbackend.mapper;

import com.campusbackend.entity.TeamExperts;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

/**
 * <p>
 * 队伍专家表 Mapper 接口
 * </p>
 *
 * @author yezi
 * @since 2025-07-26
 */
@Mapper
public interface TeamExpertsMapper extends BaseMapper<TeamExperts> {

    /**
     * 检查教师是否已经入驻该队伍
     * @param teamId 队伍ID
     * @param expertId 专家ID（教师ID）
     * @return 入驻记录数量
     */
    @Select("SELECT COUNT(*) FROM team_experts WHERE team_id = #{teamId} AND expert_id = #{expertId} AND join_status = 1")
    int checkExpertExists(@Param("teamId") Long teamId, @Param("expertId") Long expertId);

    /**
     * 插入专家入驻记录
     * @param teamExperts 专家入驻信息
     * @return 插入影响的行数
     */
    @Insert("INSERT INTO team_experts (team_id, expert_id, join_status, join_time, create_time, update_time) " +
            "VALUES (#{teamId}, #{expertId}, #{joinStatus}, #{joinTime}, #{createTime}, #{updateTime})")
    int insertExpert(TeamExperts teamExperts);
} 